# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libssh
pkgver=0.9.4
pkgrel=0
pkgdesc="Library for accessing ssh client services through C libraries"
url="https://www.libssh.org/"
arch="all"
license="LGPL-2.1-or-later BSD-2-Clause"
depends_dev="openssl-dev zlib-dev"
makedepends="$depends_dev cmake doxygen"
checkdepends="cmocka-dev"
subpackages="$pkgname-dev"
source="https://www.libssh.org/files/${pkgver%.*}/libssh-$pkgver.tar.xz
	"

# secfixes:
#   0.9.4-r0:
#     - CVE-2020-1730
#   0.9.3-r0:
#     - CVE-2019-14889
#   0.7.6-r0:
#     - CVE-2018-10933

build() {
	mkdir build && cd build
	cmake .. \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DWITH_GSSAPI=OFF \
		-DUNIT_TESTING=ON
	make
}

check() {
	case "$CARCH" in
		s390x) _disabled_tests="-E torture_threads_buffer"
	esac
	cd "$builddir/build"
	ctest --output-on-failure $_disabled_tests
}

package() {
	cd "$builddir/build"
	make DESTDIR="$pkgdir" install
}

sha512sums="38705c19c293ea5e6d286d22eb17021dbe58d88c1e647b699933aa0db9ca1174d43d1ff76c1a1b17bf2cc1a8297ec02f1a67dd9e969676dd69cf6fbdae9bc8d4  libssh-0.9.4.tar.xz"
